<template>
    <el-select
        class="type-select-input"
        v-model="value_"
        filterable
        allow-create
        default-first-option
        clearable
        placeholder="请选择分类">
        <el-option
            v-for="(item,index) in typeList"
            :key="index"
            :label="item"
            :value="item">
        </el-option>
    </el-select>
</template>

<script>
/*
 基于vue2 element-ui 类型选择组件，也可输入
 */
import {getUserWebsiteTypes} from "@/common/Tools";
export default {
    name:"TypeSelectInput",
    props:{
        value:{
            type:String,
            default:"",
        },
    },
    data(){
        return{};
    },
    computed:{
        value_:{
            get(){
                return this.value;
            },
            set(value){
                this.$emit('input',value);
            },
        },
        typeList(){ //全局添加的网站的所有类型
            return getUserWebsiteTypes(this.userWebsiteList);
        },
        userWebsiteList(){  //该登录用户的网址列表
            return this.$store.state.user.userWebsiteList;
        },
    },
}
</script>

<style scoped lang="scss">
.type-select-input{
    width: 100%;
    height: fit-content;
}
</style>
